﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System.Collections.Specialized;

namespace NeoPatterns.Patterns.Adapter
{
    /// <summary>
    /// IArrayAdapter implementation for StringCollection
    /// </summary>
    public class StringCollectionAdapter : IArrayAdapter
    {
        private StringCollection stringCollection;

        /// <summary>
        /// Returns number of strings in collection
        /// </summary>
        public int Count
        {
            get { return stringCollection.Count; }
        }

        /// <summary>
        /// Indexed accessor to get and set string entries
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public object this[int index]
        {
            get { return stringCollection[index]; }
            set { stringCollection[index] = (string)value; }
        }

        /// <summary>
        /// Target array. Must be a StringCollection
        /// </summary>
        public object Array
        {
            get { return stringCollection; }
            set { stringCollection = (StringCollection)value; }
        }
    }
}
